package prickworlds.graphics;

import static org.lwjgl.opengl.GL11.*;

/**
 * represents a texture as a part of an opengl texture
 * @author Faruk Acibal, Richard Dziambor, Christian Holzreuter, Nicolas Winkler
 * 
 */
public class PartTexture extends Texture {
	FullTexture parentTexture;

	float xLeft;
	float yTop;
	float xRight;
	float yBottom;

	@Override
	public void bind() {
		glBindTexture(GL_TEXTURE_2D, parentTexture.index);
	}

	@Override
	public void display(float x, float y, float width, float height) {
		glBegin(GL_TRIANGLE_STRIP);

		glTexCoord2f(xLeft, yTop);
		glVertex2f(x, y);

		glTexCoord2f(xRight, yTop);
		glVertex2f(x + width, y);

		glTexCoord2f(xLeft, yBottom);
		glVertex2f(x, y + height);

		glTexCoord2f(xRight, yBottom);
		glVertex2f(x + width, y + height);

		glEnd();
	}
}
